package cliente;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.Socket;

import javax.swing.JTextArea;

public class ThreadClienteSocket extends Thread{
	
	private Socket skt;
	private JTextArea areaTexto;
	private InputStream entrada;
	private BufferedReader read;
	   
	
	public ThreadClienteSocket(Socket socket, JTextArea areaTexto){
		this.skt = socket;
		this.areaTexto = areaTexto;
	}
		
	@Override
	public void run() {
		
		try {
		
			entrada = skt.getInputStream();
			read = new BufferedReader(new InputStreamReader(entrada));
			while(true){
				String entrada = read.readLine();
				if (entrada == null ) break;
				areaTexto.append(entrada + "\n");
			}
		
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		
	}

}